package com.sqk.dxpro.dxtop;

import java.io.IOException;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

public class DxTopMain {

	public static void main(String[] args) throws IllegalArgumentException, IOException, ClassNotFoundException, InterruptedException {
		Configuration conf = new Configuration();
		conf.set("mapreduce.map.memory.mb", "3072");//map大小
		conf.set("mapreduce.reduce.memory.mb", "2048");//reduce大小
		conf.set("topkey", "1");//设置用户id作为排序字段
		conf.set("topvalue", "2");//设置PV访问量作为排序值
		conf.set("topn", "5");//进行排序并且取前五条
		Job job =Job.getInstance(conf, "Dx_TopN");
		job.setJarByClass(DxTopMain.class);
		job.setMapperClass(DxTopMapper.class);
		job.setMapOutputKeyClass(Text.class);
		job.setMapOutputValueClass(Text.class);
		job.setReducerClass(DxTopReducer.class);
		job.setOutputKeyClass(Text.class);
		job.setOutputValueClass(Text.class);
		FileInputFormat.setInputPaths(job, new Path("F:\\SparkTask\\DxStaOne"));
		FileOutputFormat.setOutputPath(job, new Path("F:\\SparkTask\\DxTop"));
		System.exit(job.waitForCompletion(true) ? 0 : 1);
	}

}
